import {messages} from "share/common";
import React, {Component} from 'react';
import {Row, Col} from 'antd'
import ShowInfo from '../supplier-management/order-center/detail/show-info'
import 'styles/booking-management/ticket-info.scss'
import moment from 'moment'

class TicketInfo extends Component {

  constructor(props) {
    super(props);
    this.state = {}
  }

  onClickInfo = () => {
    const {onFormInfo} = this.props;
    onFormInfo && onFormInfo();
  }

  // 往返类型
  itineraryTypeReal = (type) => {
    if (type === 1001) {
      return messages('booking-management.key116')/*单程*/;
    } else if (type === 1002) {
      return messages('booking-management.key117')/*往返*/;
    } else {
      return '-';
    }
  }

  // 票类型  改签，退票，申请
  typeReal = (value) => {
    switch (value) {
      case 1001 :
        return messages('booking-management.key93')/*订票*/;
      case 1002 :
        return messages('booking-management.key95')/*改签*/;
      case 1003 :
        return messages('booking-management.key94')/*退票*/;
      default:
        return '-';
    }
  }

  formatDate = (date) => {
    return date ? moment(date).format('YYYY-MM-DD') : '-';
  }

  render() {
    const {info} = this.props;
    return (
      <div className='booking-ticket-info'>
        <Row>
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key118')/*出发地*/}
            value={info.fromCity || '-'}
          />
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key78')/*目的地*/}
            value={info.toCity || '-'}
          />
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key113')/*行程类型*/}
            value={this.itineraryTypeReal(info.itineraryType)}
          />
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key119')/*出发日期*/}
            value={this.formatDate(info.travelDate)}
          />
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key120')/*返回日期*/}
                    value={this.formatDate(info.returnDate)}/>
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key121')/*参与人*/}
            value={info.participantName || '-'}
          />
          <ShowInfo
            colNum={8}
            label={messages('financial-management.key131')/*申请人*/}
            value={info.applicantName || '-'}
          />
          <Col span={8}>
            <div>
              <div className='title'>{messages('components.key147'/*申请单号*/)}</div>
              {info.applicationOID ? (
                <a
                  onClick={this.onClickInfo}
                  className='label-value'
                >
                  {info.businessCode}
                </a>
              ) : '-'
              }
            </div>
          </Col>
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key124')/*申请人手机号*/}
            value={info.applicantPhone || '-'}
          />
          <ShowInfo
            colNum={8}
            label={messages('booking-management.key122')/*意向航班*/}
            value={info.intentionFlight || '-'}
          />
          <ShowInfo colNum={8} label={messages('booking-management.key7')/*类型*/} value={this.typeReal(info.type)}/>
        </Row>
      </div>
    )
  }
}

export default TicketInfo;
